package com.haotunet.app.goldtreasure.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.haotunet.app.goldtreasure.R;
import com.haotunet.app.goldtreasure.utils.ActivityUtils;
import com.haotunet.app.goldtreasure.utils.ShareStore;
import com.haotunet.app.goldtreasure.utils.Strs;
import com.haotunet.app.goldtreasure.views.TitleView;

public class ManagePwdActivity extends BaseActivity implements OnClickListener {
	private TitleView mTitleView;
	private RelativeLayout mLoginPwdLayout;
	private RelativeLayout mTradePwdLayout;
	private TextView mOperatePwdTxt;
	private ShareStore shareStore;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.activity_manage_pwd);
		shareStore = new ShareStore(this);
		initView();
	}

	private void initView() {
		mTitleView = (TitleView) findViewById(R.id.title_view_manage_pwd);
		mTitleView.getTitletextView().setVisibility(View.VISIBLE);
		mTitleView.getTitletextView().setText(getString(R.string.modify_password));
		mTitleView.getBackView().setVisibility(View.VISIBLE);
		mTitleView.getBackView().setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
		mLoginPwdLayout = (RelativeLayout) findViewById(R.id.rl_change_login_pwd);
		mTradePwdLayout = (RelativeLayout) findViewById(R.id.rl_change_trade_pwd);
		mOperatePwdTxt = (TextView) findViewById(R.id.operate_pwd);
		if (shareStore.getInt(Strs.IS_HAD_TRADING_PWD, 0) == 1) {
			mOperatePwdTxt.setText(R.string.change);
		} else {
			mOperatePwdTxt.setText(R.string.action_settings);
		}
		mLoginPwdLayout.setOnClickListener(this);
		mTradePwdLayout.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.rl_change_login_pwd:
			ActivityUtils.gotoResetPwd(ManagePwdActivity.this, 2);
			break;
		case R.id.rl_change_trade_pwd:
			if (shareStore.getInt(Strs.IS_HAD_TRADING_PWD, 0) == 1) {
				ActivityUtils.gotoResetPwd(ManagePwdActivity.this, 3);
			} else {
				ActivityUtils.gotoResetPwd(ManagePwdActivity.this, 5);
			}
			break;
		default:
			break;
		}
	}

	@Override
	protected void onActivityResult(int arg0, int arg1, Intent arg2) {
		super.onActivityResult(arg0, arg1, arg2);
	}
}
